/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;
import javax.sound.sampled.*;
import java.io.*;
/**
 *
 * @author Fernando
 */
public class Sonido extends Thread {
    private AudioInputStream stream;
        private AudioFormat format;
        private DataLine.Info info;
        private Clip clip;
        public Sonido(String nombre) {
            try {
                stream = AudioSystem.getAudioInputStream(new File(nombre));
                format = stream.getFormat();
                info = new DataLine.Info(Clip.class, stream.getFormat());
                clip = (Clip)AudioSystem.getLine(info);
            } catch (Exception e) {
            }
        }
        public void play(){
            try{
            clip.open(stream);
            }
            catch(Exception e){
            System.err.println(e.getLocalizedMessage());
            }
            clip.start();
        }
        @Override
        public void run(){
            play();
        }
}
